<?php

namespace App\Console\Commands;

use App\Utils\Lib\Redis;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class WeekCommands extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:name';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {

        $redis = Redis::createRedisObject();
        $redis->select(11);
        $day =  $redis->zRevRange('week',0,-1);
        $arr = [];
        $say=[];
        foreach ($day as $item => $value) {
            $arr['reals_name'] = $item;
            $arr['rank_browse'] = $item;
            $arr['status'] = 1;
            $arr['created_at'] = date('Y-m-d H:i:s');
            $say[] = $arr;
            DB::table('fang_statistics')->insert($arr);
        }
        $redis->del('week');

        return 0;
    }
}
